<!-- 历史查询 -->

<template>
  <WebSearch path="history">
    <template #btn>
      <BtnPrimary title="图表" :disabled="!list.length" @click="openShow()" />
      <BtnDownload :disabled="!list.length" @click="toExport" />
    </template>

    <ParamSelect label="数据类型" bind="type" :dict="GETTER.typeDict" noClear narrow />
    <ParamDate label="记录日期" bind="startTime" history noClear narrow @change="changeDate" />
  </WebSearch>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'HistorySearch',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [CORE.mixWeb('history')],

  /**
   * 本地方法 (轻量重要在前)
   */
  methods: {
    /**
     * 切换日期
     */
    changeDate(time) {
      this.param.endTime = CORE.timeNum(time, -1, 1)
    },

    /**
     * 点击导出
     */
    toExport() {
      const { refTable, param, GETTER } = this

      const type = CORE.dict(GETTER.typeDict, param.type)
      const date = CORE.dateStr(param.startTime)

      refTable.export(`数据监测 [${type}] [${date}]`)
    },
  },
}
</script>
